/// <reference path="../Scripts/jquery-1.7.1.min.js" />
/// <reference path="../Scripts/knockout-2.1.0.js" />

function UserProfileViewModel() {
    var self = this;
    // put a property loop here
    self.UserId = ko.observable();
    self.UserName = ko.observable();
    self.TS = ko.observable();
    self.CreatedBy = ko.observable();
    self.CreatedDt = ko.observable();
    self.ModifiedBy = ko.observable();
    self.ModifiedDt = ko.observable();
    self.IsActive = ko.observable();
    self.FirstName = ko.observable();
    self.LastName = ko.observable();
    self.Address = ko.observable();
    self.City = ko.observable();
    self.Region = ko.observable();
    self.PostalCode = ko.observable();
    self.OfficePhone = ko.observable();
    self.CellPhone = ko.observable();
    self.Title = ko.observable();
    self.Action = ko.observable();
    self.Caller = ko.observable();
    self.Role = ko.observable();
    self.PageSize = ko.observable();
    self.PageNumber = ko.observable();
    self.SortColumn = ko.observable();
    self.SortType = ko.observable();
    self.TotalRows = ko.observable();

    //self.eroleid = ko.observable();

    self.ActUser = ko.observable();
  

    //self.UserProfileList = ko.observableArray([]);


    self.setUserProfile = function (
			UserId, UserName, TS, CreatedBy, CreatedDt, ModifiedBy, ModifiedDt, IsActive, FirstName, LastName, Address, City, Region, PostalCode, OfficePhone, CellPhone, Title, _Action, _Caller, _Role, _PageNumber, _PageSize, _SortColumn, _SortType, _TotalRows

	) {

        UserId = _UserId;
        UserName = _UserName;
        TS = _TS;
        CreatedBy = _CreatedBy;
        CreatedDt = _CreatedDt;
        ModifiedBy = _ModifiedBy;
        ModifiedDt = _ModifiedDt;
        IsActive = _IsActive;
        FirstName = _FirstName;
        LastName = _LastName;
        Address = _Address;
        City = _City;
        Region = _Region;
        PostalCode = _PostalCode;
        OfficePhone = _OfficePhone;
        CellPhone = _CellPhone;
        Title = _Title;
        Action = _Action;
        Caller = _Caller;
        Role = _Role;
        PageSize = _PageSize
        PageNumber = _PageNumber;
        SortColumn = _SortColumn;
        SortType = _SortType;
        TotalRows = _TotalRows;

    }; //  End of set procedure 


    self.GetActiveUser = function () {
        //var self = this;



        this.Action = "GetOne";
        this.Caller = "trooks";
        this.Role = "user";
        this.PageNumber = 1;
        this.PageSize = 10;
        this.SortColumn = "UserId";
        this.SortType = "asc";
        
        jQuery.ajax({
            url: "./api/UserProfileapi/",
            type: 'get',
            data: { Action: self.Action, Caller: self.Caller, Role: self.Role, PageNumber: self.PageNumber, PageSize: self.PageSize, SortColumn: self.SortColumn, SortType: self.SortType, UserId: self.UserId },
            success: function (result) {
                self = result;
                $('#fname').text("Name: " + self.FirstName + " " + self.LastName);
                $('#address').text("Address: " + self.Address + " " + self.City + " " + self.Region);
                $('#created').text("Created: " +" "+ self.CreatedDt );
            }
        });
    }
    


}; //End of view model





